35_dsPIC & Motor Driver Prototyping
A dsPIC30 left over from a previous project was used to create some prototypes for the electrical system and processing unit.
Over Thanksgiving break, the dsPIC30 shown in Figure 1 was successfully programmed with the code shown in Figure 2 to produce a fabricated PWM signal on one of its GPIO pins. This PWM signal was used to turn on and off an LED, representing possible indicator LED’s for the device.
Figure 1: sPIC30 Lighting Up An Attached LED
Figure 2: dsPIC30 GPIO Initialization C Code
The PWM signal was created by simply adding a delay between turning on and off the output pin. This would not suffice for the final program design as the program delays block other code from executing. Either the dsPIC’s actual PWM systems would need to used, or timers could be used as well to provide better PWM signals. For now though, this PWM signal has been used in the motor driver circuit shown below in Figure 3. The PWM signal was used to run our test motor at various speeds by modifying the delay time periods in the dsPIC program.
Figure 3: Motor Driver Prototype Circuit
The graph below (Fig. 4) was obtained by measuring the voltage over a shunt resistor in series with the test motor as the motor was subjected to an increasing load at its shaft, provided by a spring of known spring constant. The point at which the motor was pulling a load of about alb was calculated to be at 23.5 seconds on the graph, corresponding to about 48mA. When plugging 48mA into our ideal equation (Eq 1) for the motor’s torque-current relationship (created from ideal specifications for the motor), the motor load supplied at the surface of the shaft is about 1.05lb. It seems like the motor operates reliably close to its predicted trends.

Equation 1
Figure 4: Graph of Motor Current Data
Finally, a pseudo program covering the overall operation of the device was created so get a better idea of how the device’s program will be structured (Fig. 5). The main loop will constantly be reading in data from the motor position and load feedback as well as values from the EMG system. When threshold values are hit, corresponding interrupts will determine whether those values are significant enough to act on or not. Also in the interrupts are User I/O monitors which will simply be triggered when one of the User I/O switches changes state. More detailed pseudo-code for the interrupts was worked out as in Figure 6.
Figure 5: Program Structure
Figure 6: Pseudo Program of Interrupt Service Routines